using System.Linq;
using UnityEngine;

namespace IQIGame.Onigao.GamePlay
{
    public partial class UIMapManager
    {
        private class UIQuestAreaSymbol : UINormalMapSymbol
        {
            protected override void Draw()
            {
                var questCid = GameDataCenter.PlayerData.quest.trackQuestCid;
                var config = TableCenter.quest.Get(questCid);
                //配置的是世界地图半径,单位厘米，需要乘factor 再乘2
                var rangeSize = (config.TargetRangeSize?.FirstOrDefault() ?? 0) * Mathf.Abs(owner.factor) * 2 * 0.01f;
                var w = rangeSize / ui.icon.pixelsPerUnit;
                var h = rangeSize / ui.icon.pixelsPerUnit;
                ui.icon.rectTransform.anchorMax = ui.icon.rectTransform.anchorMin;
                size = new Vector2(w, h);
                base.Draw();
            }
        }
    }
}